VERSION 5.00
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmPUR510 
   BackColor       =   &H00800000&
   Caption         =   "PUR500"
   ClientHeight    =   8520
   ClientLeft      =   480
   ClientTop       =   240
   ClientWidth     =   11010
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   8520
   ScaleWidth      =   11010
   Begin VB.CommandButton CmdPreview 
      Caption         =   "Preview"
      Height          =   456
      Left            =   1200
      TabIndex        =   66
      Top             =   7920
      Width           =   1035
   End
   Begin VB.TextBox txtOHBTA 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   4335
      Locked          =   -1  'True
      TabIndex        =   62
      Top             =   7545
      Width           =   1170
   End
   Begin VB.TextBox txtOHTAM 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   288
      Left            =   1425
      Locked          =   -1  'True
      TabIndex        =   61
      Top             =   7545
      Width           =   1170
   End
   Begin VB.Frame FramePOLine 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   1650
      Left            =   195
      TabIndex        =   35
      Top             =   3000
      Width           =   10635
      Begin VB.TextBox txtOLRCW 
         Height          =   285
         Left            =   6960
         TabIndex        =   68
         Top             =   450
         Width           =   975
      End
      Begin VB.TextBox txtOLRCQ 
         Height          =   288
         Left            =   3120
         TabIndex        =   67
         Top             =   480
         Width           =   975
      End
      Begin MSDataListLib.DataCombo cboOLITN 
         Bindings        =   "frmPUR510.frx":0000
         Height          =   315
         Left            =   5655
         TabIndex        =   65
         Top             =   90
         Visible         =   0   'False
         Width           =   4050
         _ExtentX        =   7144
         _ExtentY        =   556
         _Version        =   393216
         ListField       =   "IMITD"
         BoundColumn     =   "IMITN"
         Text            =   ""
      End
      Begin VB.ComboBox cboOLSTT 
         ForeColor       =   &H000000FF&
         Height          =   315
         ItemData        =   "frmPUR510.frx":0015
         Left            =   8955
         List            =   "frmPUR510.frx":002B
         TabIndex        =   47
         Top             =   1230
         Width           =   1425
      End
      Begin VB.TextBox txtOLBLA 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   5655
         TabIndex        =   46
         Top             =   1185
         Width           =   975
      End
      Begin VB.TextBox txtOLLAM 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         TabIndex        =   45
         Top             =   1200
         Width           =   975
      End
      Begin VB.ComboBox cboOLPER 
         Height          =   315
         ItemData        =   "frmPUR510.frx":007A
         Left            =   8955
         List            =   "frmPUR510.frx":0087
         TabIndex        =   44
         Top             =   825
         Width           =   1410
      End
      Begin VB.TextBox txtOLUMP 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         TabIndex        =   43
         Top             =   855
         Width           =   975
      End
      Begin VB.TextBox txtOLODW 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   5655
         TabIndex        =   42
         Top             =   450
         Width           =   975
      End
      Begin VB.TextBox txtOLODQ 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         TabIndex        =   41
         Top             =   480
         Width           =   975
      End
      Begin VB.TextBox txtOLITN 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   5685
         TabIndex        =   40
         Top             =   90
         Width           =   1425
      End
      Begin VB.TextBox txtOLITD 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   7140
         Locked          =   -1  'True
         TabIndex        =   39
         Top             =   90
         Width           =   2550
      End
      Begin VB.TextBox txtOLPOL 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1890
         Locked          =   -1  'True
         TabIndex        =   38
         Top             =   75
         Width           =   525
      End
      Begin VB.TextBox txtOLLDT 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   8955
         TabIndex        =   37
         Top             =   480
         Width           =   1140
      End
      Begin VB.TextBox txtOLPDC 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   5670
         TabIndex        =   36
         Top             =   825
         Width           =   990
      End
      Begin VB.Label lbl 
         Alignment       =   1  'Right Justify
         BackStyle       =   0  'Transparent
         Caption         =   "Line status"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Index           =   23
         Left            =   7905
         TabIndex        =   58
         Top             =   1305
         Width           =   975
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "B line amount"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   22
         Left            =   4320
         TabIndex        =   57
         Top             =   1215
         Width           =   1215
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Line amount"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   21
         Left            =   600
         TabIndex        =   56
         Top             =   1260
         Width           =   1110
      End
      Begin VB.Label lbl 
         Alignment       =   1  'Right Justify
         BackStyle       =   0  'Transparent
         Caption         =   "Price Per"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   20
         Left            =   8025
         TabIndex        =   55
         Top             =   870
         Width           =   855
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Unit price"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   19
         Left            =   840
         TabIndex        =   54
         Top             =   885
         Width           =   870
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Weight PO/RC"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   18
         Left            =   4245
         TabIndex        =   53
         Top             =   495
         Width           =   1290
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Quantity PO/RC"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   17
         Left            =   255
         TabIndex        =   52
         Top             =   510
         Width           =   1455
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Item No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   16
         Left            =   4785
         TabIndex        =   51
         Top             =   105
         Width           =   750
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "PO lines"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   15
         Left            =   990
         TabIndex        =   50
         Top             =   105
         Width           =   720
      End
      Begin VB.Label lbl 
         Alignment       =   1  'Right Justify
         BackStyle       =   0  'Transparent
         Caption         =   "Line date"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   24
         Left            =   8040
         TabIndex        =   49
         Top             =   540
         Width           =   840
      End
      Begin VB.Line Line2 
         X1              =   3075
         X2              =   2940
         Y1              =   525
         Y2              =   735
      End
      Begin VB.Line Line3 
         X1              =   6855
         X2              =   6675
         Y1              =   495
         Y2              =   705
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "% Discount"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Index           =   25
         Left            =   4440
         TabIndex        =   48
         Top             =   885
         Width           =   1095
      End
   End
   Begin VB.CommandButton cmdCloseLine 
      Caption         =   "Close &Line"
      Height          =   456
      Left            =   7080
      TabIndex        =   32
      Top             =   7920
      Width           =   1080
   End
   Begin VB.CommandButton cmdClosePO 
      Caption         =   "Clo&se PO"
      Height          =   456
      Left            =   5880
      TabIndex        =   31
      Top             =   7920
      Width           =   1080
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   456
      Left            =   2280
      TabIndex        =   30
      Top             =   7920
      Width           =   1128
   End
   Begin VB.Frame FramePO 
      BackColor       =   &H00800000&
      BorderStyle     =   0  'None
      Caption         =   "Frame2"
      Height          =   2145
      Left            =   45
      TabIndex        =   6
      Top             =   825
      Width           =   10860
      Begin Crystal.CrystalReport CrystalReport1 
         Left            =   5880
         Top             =   1080
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   348160
         PrintFileLinesPerPage=   60
      End
      Begin MSDataListLib.DataCombo cboOHCUR 
         Bindings        =   "frmPUR510.frx":00A8
         Height          =   315
         Left            =   1965
         TabIndex        =   34
         Top             =   1770
         Width           =   1035
         _ExtentX        =   1826
         _ExtentY        =   556
         _Version        =   393216
         ListField       =   "CMCCD"
         BoundColumn     =   "CMCCD"
         Text            =   ""
      End
      Begin VB.TextBox txtOHCUR 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1980
         TabIndex        =   33
         Top             =   1785
         Width           =   735
      End
      Begin MSDataListLib.DataCombo cboOHVDN 
         Bindings        =   "frmPUR510.frx":00BD
         Height          =   315
         Left            =   1980
         TabIndex        =   29
         Top             =   1320
         Visible         =   0   'False
         Width           =   3105
         _ExtentX        =   5477
         _ExtentY        =   556
         _Version        =   393216
         ListField       =   "VMNME"
         BoundColumn     =   "VMVDN"
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo cboOHCNO 
         Bindings        =   "frmPUR510.frx":00D2
         Height          =   330
         Left            =   1995
         TabIndex        =   28
         Top             =   885
         Visible         =   0   'False
         Width           =   3105
         _ExtentX        =   5477
         _ExtentY        =   582
         _Version        =   393216
         ListField       =   "CMNME"
         BoundColumn     =   "CMCNO"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox txtOHPON 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1995
         TabIndex        =   17
         Top             =   495
         Width           =   1395
      End
      Begin VB.TextBox txtOHPOD 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   5760
         TabIndex        =   16
         Top             =   465
         Width           =   1170
      End
      Begin VB.TextBox txtOHCNO 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1995
         TabIndex        =   15
         Top             =   900
         Width           =   750
      End
      Begin VB.TextBox txtOHVDN 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   1995
         TabIndex        =   14
         Top             =   1335
         Width           =   780
      End
      Begin VB.TextBox txtOHRQD 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   9000
         TabIndex        =   13
         Top             =   495
         Width           =   1170
      End
      Begin VB.TextBox txtOHEXR 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   8985
         TabIndex        =   12
         Top             =   1725
         Width           =   1170
      End
      Begin VB.TextBox txtCMNME 
         BeginProperty Font 
            Name            =   "VNI-Helve"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   2820
         TabIndex        =   11
         Top             =   900
         Width           =   2235
      End
      Begin VB.ComboBox cboOHCPO 
         Height          =   315
         ItemData        =   "frmPUR510.frx":00E7
         Left            =   9000
         List            =   "frmPUR510.frx":00F4
         TabIndex        =   10
         Top             =   885
         Width           =   1635
      End
      Begin VB.TextBox txtVMNME 
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   288
         Left            =   2805
         TabIndex        =   9
         Top             =   1335
         Width           =   2235
      End
      Begin VB.ComboBox cboOHPOS 
         ForeColor       =   &H000000FF&
         Height          =   315
         ItemData        =   "frmPUR510.frx":0124
         Left            =   9000
         List            =   "frmPUR510.frx":013A
         TabIndex        =   8
         Top             =   1305
         Width           =   1635
      End
      Begin VB.ComboBox cboOHPOT 
         Height          =   315
         ItemData        =   "frmPUR510.frx":0189
         Left            =   4920
         List            =   "frmPUR510.frx":0196
         TabIndex        =   7
         Top             =   0
         Width           =   1365
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Purchase Order No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   27
         Top             =   510
         Width           =   1620
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Purchase Order Date"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   3
         Left            =   3780
         TabIndex        =   26
         Top             =   495
         Width           =   1845
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Purchase Order Type"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0080FFFF&
         Height          =   255
         Index           =   4
         Left            =   2865
         TabIndex        =   25
         Top             =   90
         Width           =   1845
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Customer No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   5
         Left            =   630
         TabIndex        =   24
         Top             =   930
         Width           =   1110
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Vendor No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   6
         Left            =   795
         TabIndex        =   23
         Top             =   1365
         Width           =   945
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Currency Code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   7
         Left            =   465
         TabIndex        =   22
         Top             =   1785
         Width           =   1290
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Date Requested"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   8
         Left            =   7470
         TabIndex        =   21
         Top             =   495
         Width           =   1455
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Exchange Rate"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   9
         Left            =   7605
         TabIndex        =   20
         Top             =   1740
         Width           =   1320
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Customer Type"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00E0E0E0&
         Height          =   255
         Index           =   10
         Left            =   7590
         TabIndex        =   19
         Top             =   915
         Width           =   1335
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "P.O. status"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Index           =   13
         Left            =   7890
         TabIndex        =   18
         Top             =   1335
         Width           =   1035
      End
   End
   Begin MSAdodcLib.Adodc Adodc5 
      Height          =   375
      Left            =   8910
      Top             =   30
      Visible         =   0   'False
      Width           =   2025
      _ExtentX        =   3572
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "5 CUR_EX"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc4 
      Height          =   360
      Left            =   8190
      Top             =   345
      Visible         =   0   'False
      Width           =   1755
      _ExtentX        =   3096
      _ExtentY        =   635
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "4 POL"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc3 
      Height          =   345
      Left            =   8190
      Top             =   30
      Visible         =   0   'False
      Width           =   1725
      _ExtentX        =   3043
      _ExtentY        =   609
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "3 IIM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   6870
      Top             =   375
      Visible         =   0   'False
      Width           =   1920
      _ExtentX        =   3387
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "2. AVM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   6885
      Top             =   30
      Visible         =   0   'False
      Width           =   1935
      _ExtentX        =   3413
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1 RCM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   456
      Left            =   3480
      TabIndex        =   5
      Top             =   7920
      Width           =   1080
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   456
      Left            =   4680
      TabIndex        =   4
      Top             =   7920
      Width           =   1080
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   456
      Left            =   8280
      TabIndex        =   3
      Top             =   7920
      Width           =   1044
   End
   Begin VB.CommandButton cmdReview 
      Caption         =   "&Review PO"
      Height          =   456
      Left            =   75
      TabIndex        =   2
      Top             =   7920
      Width           =   1035
   End
   Begin MSDataGridLib.DataGrid grdPOL 
      Bindings        =   "frmPUR510.frx":01C6
      Height          =   2220
      Left            =   195
      TabIndex        =   59
      Top             =   5145
      Width           =   10695
      _ExtentX        =   18865
      _ExtentY        =   3916
      _Version        =   393216
      BackColor       =   -2147483624
      ForeColor       =   8388608
      HeadLines       =   1
      RowHeight       =   15
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   13
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "OLPOL"
         Caption         =   "line"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "OLITN"
         Caption         =   "Item"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "OLITD"
         Caption         =   "Item Description"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column04 
         DataField       =   "OLODQ"
         Caption         =   "Qty."
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column05 
         DataField       =   "OLRCQ"
         Caption         =   "RC. Qty."
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column06 
         DataField       =   "OLODW"
         Caption         =   "Wgt."
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column07 
         DataField       =   "OLRCW"
         Caption         =   "RC. Wgt."
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column08 
         DataField       =   "OLUMP"
         Caption         =   "Unit price"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column09 
         DataField       =   "OLPER"
         Caption         =   "Price per"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column10 
         DataField       =   "OLLAM"
         Caption         =   "Line amount"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column11 
         DataField       =   "OLBLA"
         Caption         =   "B line amount"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column12 
         DataField       =   "OLSTT"
         Caption         =   "Status"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   14.74
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   329.953
         EndProperty
         BeginProperty Column02 
            ColumnWidth     =   1184.882
         EndProperty
         BeginProperty Column03 
            ColumnWidth     =   2610.142
         EndProperty
         BeginProperty Column04 
            ColumnWidth     =   705.26
         EndProperty
         BeginProperty Column05 
            ColumnWidth     =   720
         EndProperty
         BeginProperty Column06 
            ColumnWidth     =   659.906
         EndProperty
         BeginProperty Column07 
            ColumnWidth     =   764.787
         EndProperty
         BeginProperty Column08 
            ColumnWidth     =   810.142
         EndProperty
         BeginProperty Column09 
            ColumnWidth     =   750.047
         EndProperty
         BeginProperty Column10 
            ColumnWidth     =   959.811
         EndProperty
         BeginProperty Column11 
            ColumnWidth     =   840.189
         EndProperty
         BeginProperty Column12 
            ColumnWidth     =   1110.047
         EndProperty
      EndProperty
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Total amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   12
      Left            =   3075
      TabIndex        =   64
      Top             =   7590
      Width           =   1215
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "P.O. Amount"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   11
      Left            =   240
      TabIndex        =   63
      Top             =   7590
      Width           =   1215
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Purchase Order lines"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   255
      Index           =   14
      Left            =   45
      TabIndex        =   60
      Top             =   4815
      Width           =   1845
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Purchase Order Control"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   480
      Index           =   1
      Left            =   1920
      TabIndex        =   1
      Top             =   225
      Width           =   4620
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "PUR510"
      BeginProperty Font 
         Name            =   "VNI-Present"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   450
      Index           =   0
      Left            =   75
      TabIndex        =   0
      Top             =   -45
      Width           =   1830
   End
End
Attribute VB_Name = "frmPUR510"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CustType(3), StaOrd(6), POType(3), OldOHPON, Per(3) As String, NewTrans As Byte
Dim WithEvents rst As ADODB.Recordset
Attribute rst.VB_VarHelpID = -1
Dim sql As String
Dim oldReview, oldEdit, oldSave, oldCancel, olddelline, oldCloseline, oldClosePO As Boolean


Private Sub cboOHCNO_Click(Area As Integer)
If Area = 2 Then
    txtOHCNO = cboOHCNO.BoundText
    txtCMNME = cboOHCNO.Text
    cboOHCNO.Visible = False
End If
End Sub

Private Sub cboOHCPO_Click()
'txtOHVDN.SetFocus
End Sub

Private Sub cboOHCUR_Click(Area As Integer)
If Area = 2 Then
    txtOHCUR = cboOHCUR.BoundText
    txtOHEXR = Find("CCI", "CICCR", " where CICCD='" & txtOHCUR & "'")
End If
End Sub

Private Sub cboOHVDN_Click(Area As Integer)
If Area = 2 Then
    txtOHVDN = cboOHVDN.BoundText
    txtVMNME = cboOHVDN.Text
    cboOHVDN.Visible = False
End If
End Sub

Private Sub cboOLITN_Click(Area As Integer)
If Area = 2 Then
    txtOLITN = cboOLITN.BoundText
    txtOLITD = cboOLITN.Text
    cboOLITN.Visible = False
End If
End Sub

Private Sub cboOLPER_Click()
Select Case cboOLPER.ListIndex + 1
    Case 1
        txtOLLAM = CLng(Val(txtOLODQ) * (Val(txtOLUMP) - (Val(txtOLUMP) * Val(txtOLPDC) / 100)))
        txtOLBLA = Val(txtOLODQ) * (Val(txtOLUMP) - (Val(txtOLUMP) * Val(txtOLPDC) / 100)) * Val(txtOHEXR)
    Case 2
        txtOLLAM = CLng(Val(txtOLODW) * (Val(txtOLUMP) - (Val(txtOLUMP) * Val(txtOLPDC) / 100)))
        txtOLBLA = Val(txtOLODW) * (Val(txtOLUMP) - (Val(txtOLUMP) * Val(txtOLPDC) / 100)) * Val(txtOHEXR)
End Select
End Sub

Private Sub cmdAddnew_Click()
NewTrans = True
ISADDING = True
ISEDITING = True
WriteToScreen
ButtonStatus ("NP")
txtOHPON.SetFocus
End Sub

Private Sub CmdCancel_Click()
NewTrans = False
ISADDING = False
ISEDITING = False
WriteToScreen
ButtonStatus ("cl")
End Sub

Private Sub cmdCloseLine_Click()
    Dim recPOL As Recordset, Line, Item, WGT, Unt, Status
    Line = txtOLPOL
    Item = txtOLITN
    Status = cboOLSTT.ListIndex + 1
    If (cboOHPOS.ListIndex + 1) = 6 Then
        MsgBox "This Purchase Order had been cancel"
        Exit Sub
    Else
    If Status = 6 Then
        MsgBox "This Item had been deleted"
    Else
        If Status = 5 Then
            MsgBox "This Item had been closed before"
        Else
            CloseLine Item, Line, WGT, Unt, Status
        End If
    End If
        ButtonStatus ("clne")
        WriteToScreen
    End If
End Sub

Private Sub cmdClosePO_Click()
    ClosePO
    ButtonStatus ("CP")
    WriteToScreen
End Sub

Private Sub cmddelline_Click()
Dim vb
If (txtOHPON.Text <> "") And (txtOLITN.Text <> "") Then
    sql = ""
    sql = "select olstt from poh,pol where pol.olitn='" & Trim(txtOLITN.Text) & "' and olstt='1' and poh.ohpos='1'"
    Set rst = New ADODB.Recordset
    rst.Open sql, ConnectString, adOpenKeyset, adLockOptimistic
    If rst.RecordCount > 0 Then
        vb = MsgBox(" Do you want delete this line ?", vbDefaultButton2 + vbOKCancel, "Deleting...")
        If vb = vbOK Then
            sql = ""
            sql = "delete from POL where OLPON='" & Trim(txtOHPON.Text) & "' AND  OLITN='" & Trim(txtOLITN.Text) & "'"
            DBconn.Execute (sql)
            WriteToScreen
        Else
            Exit Sub
        End If
    Else
        MsgBox "Can not delete this line !", vbCritical, "Warning"
        Exit Sub
    End If
Else
    MsgBox "The TextBox Order No or Item No is Empty...!", vbCritical, "Warning"
End If
End Sub
Private Sub cmdEdit_Click()
    If TestPOStatus() = False Then
        Exit Sub
    Else
        NewTrans = False
        ISADDING = False
        ISEDITING = True
        'WriteToScreen
        ButtonStatus ("edit")
    End If
End Sub

Private Sub cmdexit_Click()
    Unload frmPUR510
End Sub

Private Sub cmdNewItem_Click()
'NewTrans = True
If txtOHPON <> "" Then
    ISADDING = True
    ISEDITING = True
    WriteToScreen
    ButtonStatus ("NL")
Else
    MsgBox "Not yet Purchase Order"
End If
End Sub

Private Sub CmdPreview_Click()
    Dim ReportName As String
    ButtonStatus ("PRE")
    ReportName = "request.rpt"
    If txtOHPON = "" Or IsNull(txtOHPON) Then
        MsgBox "You must chose Purchase Order No."
        Exit Sub
    Else
     CrystalReport1.ReportFileName = DDAN & "\" & ReportName
     CrystalReport1.RetrieveStoredProcParams
     CrystalReport1.StoredProcParam(0) = txtOHPON
     CrystalReport1.Action = 1
     End If
End Sub

Private Sub cmdReview_Click()
   
frmReview.Tag = "PUR500"
frmReview.Show 1
ISEDITING = False
ISADDING = False
If frmReview.Tag <> "" Then
    txtOHPON = frmReview.Tag
    Unload frmReview
    WriteToScreen
    ButtonStatus ("REV")

End If
End Sub
Sub WriteToScreen()
If NewTrans Then ' tao moi
    cboOHPOT.ListIndex = 0
    txtOHPON = ""
    txtOHPOD = WorkingDate
    txtOHRQD = ""
    txtOHCNO = ""
    txtCMNME = ""
    txtOHVDN = ""
    txtVMNME = ""
    cboOHCPO = ""
    cboOHPOS.ListIndex = 0
    cboOHCUR = ""
    txtOHCUR = ""
    txtOHEXR = 0
    txtOHTAM = 0
    txtOHBTA = 0
End If

If ISADDING Then ' them moi
   txtOLITN = ""
   txtOLLDT = WorkingDate
   txtOLITD = ""
   txtOLPOL = 0
   txtOLODQ = 0
   txtOLODW = 0
   txtOLUMP = 0
   txtOLLAM = ""
   cboOLPER = ""
   txtOLBLA = ""
   cboOLSTT.ListIndex = 0
   StrCV = ""
   txtOLRCQ = 0
   txtOLRCW = 0
   txtOLPDC = 0
Else 'Sua chua
    Dim recPOL As Recordset
    'FROM AVM LEFT JOIN IIM ON AVM.VMVDN = IIM.IMVDC
    If txtOLPOL <> "" Then
        Set recPOL = DBconn.Execute("select POL.*,POH.* from POL LEFT JOIN POH ON POL.OLPON=POH.OHPON where POL.OLPON='" & txtOHPON & "' and OLPOL='" & txtOLPOL & "'")
    Else
        Set recPOL = DBconn.Execute("select POL.*,POH.* from POL LEFT JOIN POH ON POL.OLPON=POH.OHPON where POL.OLPON='" & txtOHPON & "' Order by POL.OLPOL")
    End If
    If Not recPOL.EOF Then
        With recPOL
            cboOHPOT.ListIndex = Val(!OHPOT) - 1
            txtOHPON = !OHPON
            OldOHPON = txtOHPON
            txtOHPOD = !OHPOD
            If IsNull(!OHRQD) Then
                txtOHRQD = ""
            Else
                txtOHRQD = !OHRQD
            End If
            txtOHCNO = !OHCNO
            txtCMNME = Find("RCM", "CMNME", " WHERE CMCNO='" & txtOHCNO & "'")
            txtOHVDN = !OHVDN
            txtVMNME = Find("AVM", "VMNME", " WHERE VMVDN='" & txtOHVDN & "'")
            cboOHCPO.ListIndex = Val(!OHCPO) - 1
            For i = 0 To cboOHPOS.ListCount - 1
                If Left(cboOHPOS.List(i), 1) = !OHPOS Then
                    cboOHPOS.ListIndex = i
                    Exit For
                End If
            Next i
            
            cboOHCUR = !OHCUR
            txtOHCUR = !OHCUR
            txtOHEXR = !OHEXR
            txtOHTAM = !OHTAM
            txtOHBTA = !OHBTA
            txtOLITN = !OLITN
            txtOLITD = Find("IIM", "IMITD", "Where IMITN='" & txtOLITN & "'")
            txtOLPOL = !OLPOL
            txtOLODQ = !OLODQ
            txtOLODW = !OLODW
            txtOLUMP = !OLUMP
            txtOLPDC = !OLPDC
            txtOLLAM = !OLLAM
            cboOLPER.ListIndex = Val(!OLPER) - 1
            txtOLBLA = !OLBLA
            cboOLSTT.ListIndex = Val(!OLSTT) - 1
            txtOLRCQ = !OLRCQ
            txtOLRCW = !OLRCW
            txtOLLDT = !OLLDT
        End With
     End If
End If

Adodc4.RecordSource = "select POL.*,POH.* from POL " & _
    " LEFT JOIN POH ON POL.OLPON=POH.OHPON " & _
    " where POL.OLPON='" & txtOHPON & "'" & _
    " Order by OLPOL"

Adodc4.Refresh
End Sub



Private Sub cmdSave_Click()
If TestPOStatus() = False Then
    Exit Sub
Else
    WriteToFile
    NewTrans = False
    ISADDING = False
    ISEDITING = False
    ButtonStatus ("SV")
End If
End Sub

Private Sub Form_Load()
    NewTrans = False
    ISEDITING = False
    ISADDING = False
    OpenFile
    ButtonStatus ("start")
End Sub

Private Sub grdPOL_Click()
    If Adodc4.Recordset.AbsolutePosition = -1 Then
        WriteToScreen
    Exit Sub
    End If
    txtOLPOL = grdPOL.Columns(1).value
    WriteToScreen
     If SELECTROW = "" Then SELECTROW = 1
    Adodc4.Recordset.AbsolutePosition = SELECTROW
End Sub
Private Sub grdPOL_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    If LastRow = Empty Then
    WriteToScreen
    Exit Sub
    End If
    SELECTROW = Adodc4.Recordset.Bookmark
End Sub
Private Sub txtOHCNO_KeyPress(KeyAscii As Integer)
Dim Result As String
If KeyAscii = 13 Then
    Result = Find("RCM", "CMNME", "WHERE CMCNO='" & txtOHCNO & "'")
    If Result = "" Then
        cboOHCNO.Visible = True
        cboOHCNO.SetFocus
    Else
        cboOHCNO.Visible = False
        txtCMNME = Result
        cboOHCPO.SetFocus
    End If
End If
End Sub

Private Sub txtOHEXR_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtOLITN.SetFocus
End If
End Sub

Private Sub txtOHPOD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtOHRQD.SetFocus
End If
End Sub

Private Sub txtOHPON_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    If Not IsNumeric(txtOHPON.Text) Then
        MsgBox "Input string of Digit", vbCritical, "Warning"
        txtOHPON.SetFocus
        Exit Sub
    End If
        If txtOHPON = "" Then
            MsgBox "Not let blank PO"
            Exit Sub
        Else
            Result = Find("POH", "OHPON", "WHERE OHPON='" & txtOHPON & "'")
        If Result = "" Then
            txtOHPOD.SetFocus
        Else
            MsgBox "Doc Number is already exist"
            NewTrans = False
            ISADDING = False
            ISEDITING = False
            WriteToScreen
            ButtonStatus ("start")
            txtOHRQD.SetFocus
        End If
    End If
End If
End Sub

Private Sub txtOHPON_LostFocus()
'If Not IsNumeric(txtOHPON.Text) Then
'MsgBox "Input string of Digit"
'txtOHPON.SetFocus
'End If
End Sub

Private Sub txtOHRQD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtOHCNO.SetFocus
End If
End Sub

Private Sub txtOHVDN_KeyPress(KeyAscii As Integer)
Dim Result As String
If KeyAscii = 13 Then
    Result = Find("AVM", "VMNME", "WHERE VMVDN='" & txtOHVDN & "'")
    If Result = "" Then
        cboOHVDN.Visible = True
        cboOHVDN.SetFocus
    Else
        cboOHVDN.Visible = False
        txtVMNME = Result
        cboOHPOS.SetFocus
    End If
End If
End Sub

Private Sub txtOLITN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Dim Result As String
    Result = Find("IIM", "IMITD", "WHERE IMITN='" & txtOLITN & "'")
    If Result = "" Then
        cboOLITN.Visible = True
        cboOLITN.SetFocus
    Else
        txtOLITD = Result
        cboOLITN.Visible = False
        txtOLODQ.SetFocus
    End If
   
End If
End Sub
Sub OpenFile()
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select * from RCM"
Adodc1.Refresh

Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "Select * from AVM"
Adodc2.Refresh

FieldDel = "IMRID"
DelStatus = "IZ"
sql = "Select * from IIM where " & FieldDel & " <>'" & DelStatus & "' "
Adodc3.ConnectionString = ConnectString
Adodc3.ConnectionTimeout = 10
Adodc3.CommandType = adCmdText
Adodc3.RecordSource = sql
Adodc3.Refresh

Adodc4.ConnectionString = ConnectString
Adodc4.ConnectionTimeout = 10
Adodc4.CommandType = adCmdText
Adodc4.RecordSource = "Select POL.*,POH.* from POL " & _
    " LEFT JOIN POH ON POL.OLPON=POH.OHPON where POH.OHPON ='" & txtOHPON & "'"
Adodc4.Refresh

Adodc5.ConnectionString = ConnectString
Adodc5.ConnectionTimeout = 10
Adodc5.CommandType = adCmdText
Adodc5.RecordSource = "Select * from CCM"
Adodc5.Refresh

' Create array from combobox Custtype,StatusOrder, ValuePer
CustType(1) = "1 Production"
CustType(2) = "2 Local Purchasing"
CustType(3) = "3 Import"
StaOrd(1) = "1 New"
StaOrd(2) = "2 Modifine"
StaOrd(3) = "3 Shop Order"
StaOrd(4) = "4 Started Product"
StaOrd(5) = "5 Completed"
StaOrd(6) = "6 Cancel"
Per(1) = "Unt"
Per(2) = "Wgt"
Per(3) = "All"
POType(1) = "Product"
POType(2) = "Local Purchasing"
POType(3) = "Import"

End Sub

Sub ButtonStatus(tdisplay)
Dim BSTT

If tdisplay = "edit" Then
    oldReview = cmdReview.Enabled
    oldEdit = cmdEdit.Enabled
    oldSave = cmdSave.Enabled
    oldCancel = CmdCancel.Enabled
    oldClosePO = cmdClosePO.Enabled
    oldCloseline = cmdCloseLine.Enabled
End If
    
Select Case LCase(tdisplay)

    Case "start"
        cmdReview.Enabled = True
        CmdPreview.Enabled = False
        cmdEdit.Enabled = False
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = False
        cmdCloseLine.Enabled = False
    Case "rev" 'Review
        cmdReview.Enabled = True
        CmdPreview.Enabled = True
        cmdEdit.Enabled = True
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = True
        cmdCloseLine.Enabled = True

    Case "edit" ' new purchase order
        cmdReview.Enabled = False
        CmdPreview.Enabled = False
        cmdEdit.Enabled = False
        cmdSave.Enabled = True
        CmdCancel.Enabled = True
        cmdClosePO.Enabled = False
        cmdCloseLine.Enabled = False
    Case "pre" 'Preview Purchase order
        cmdReview.Enabled = True
        CmdPreview.Enabled = True
        cmdEdit.Enabled = True
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = True
        cmdCloseLine.Enabled = True
    Case "sv" 'Save
        cmdReview.Enabled = True
        CmdPreview.Enabled = True
        cmdEdit.Enabled = True
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = True
        cmdCloseLine.Enabled = True
    Case "cl" 'cancel
        cmdReview.Enabled = oldReview
        CmdPreview.Enabled = oldPreview
        cmdEdit.Enabled = oldEdit
        cmdSave.Enabled = oldSave
        CmdCancel.Enabled = oldCancel
        cmdClosePO.Enabled = True
        cmdCloseLine.Enabled = True
    Case "cp" 'Close purchase order
        cmdReview.Enabled = True
        CmdPreview.Enabled = True
        cmdEdit.Enabled = False
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = False
        cmdCloseLine.Enabled = False
    Case "clne" 'Close line
        cmdReview.Enabled = True
        CmdPreview.Enabled = True
        cmdEdit.Enabled = True
        cmdSave.Enabled = False
        CmdCancel.Enabled = False
        cmdClosePO.Enabled = True
        cmdCloseLine.Enabled = True
End Select
    
FramePO.Enabled = NewTrans Or ISEDITING
FramePOLine.Enabled = ISEDITING
End Sub

Sub WriteToFile()
    Dim reqdte As String
If NewTrans Then ' nhap moi them vao POH
    txtOHLDT = Format(Now(), "yyyy-mm-dd hh:mm:ss")
    txtOHPOD = Format(WorkingDate, "yyyy-mm-dd hh:mm:ss")
    If txtOHRQD = "" Then
        reqdte = "null"
    Else
        reqdte = "'" & Format(txtOHRQD, "yyyy-mm-dd hh:mm:ss") & "'"
        
    End If
    
    sql = "Insert into POH (OHLDT,OHPOD,OHRQD,OHRID" & _
    ",OHPON,OHCNO,OHVDN" & _
    ",OHCPO,OHPOS,OHCUR,OHPOT" & _
    ",OHEXR,OHTAM,OHBTA) values " & _
    "('" & txtOHLDT & "','" & txtOHPOD & "'," & reqdte & ",'OM'" & _
    ",'" & txtOHPON & "','" & txtOHCNO & "','" & txtOHVDN & "'" & _
    ",'" & cboOHCPO.ListIndex + 1 & "','" & cboOHPOS.ListIndex + 1 & "','" & cboOHCUR.Text & "','" & cboOHPOT.ListIndex + 1 & "'" & _
    "," & txtOHEXR & "," & txtOHTAM & "," & txtOHBTA & ")"
    'MsgBox SQL
    DBconn.Execute (sql)
End If
Dim recPOL As Recordset
If ISADDING Then ' nhap moi them vao POl
    Set recPOL = DBconn.Execute("Select * from POL where OLPON='" & txtOHPON & "' order by OLPOL Desc ")
    If recPOL.EOF Then
        txtOLPOL = 1
    Else
        txtOLPOL = recPOL!OLPOL + 1
    End If
    txtOLLDT = Format(txtOLLDT, "yyyy-mm-dd hh:mm:ss")
    
    sql = "Insert into POL(OLLDT,OLITN,OLITD,OLRID,OLBLA,OLLUS" & _
    ",OLUMP,OLLAM,OLPER,OLSTT" & _
    ",OLPOL,OLODQ,OLODW,OLPON,OLPDC,OLRCQ,OLRCW) values " & _
    "('" & txtOLLDT & "','" & txtOLITN & "','" & txtOLITD & "','OM'," & txtOLBLA & ",'" & UserLogin & "'" & _
    ",'" & txtOLUMP & "','" & txtOLLAM & "','" & cboOLPER.ListIndex + 1 & "','" & cboOLSTT.ListIndex + 1 & "'" & _
    ",'" & txtOLPOL & "'," & txtOLODQ & "," & txtOLODW & ",'" & txtOHPON & "'," & txtOLPDC & " ,0,0)"
    'MsgBox SQL
    DBconn.Execute (sql)
    WriteToIIM txtOLODW, txtOLODQ
    WriteToITH txtOLODW, txtOLODQ
Else 'Sua chua du lieu
    
    sql = "Update POH SET  OHLDT='" & txtOHLDT & "',OHPOD='" & Format(txtOHPOD, "mm/dd/yy") & "',OHRQD='" & Format(txtOHRQD, "mm/dd/yy") & "'" & _
    ",OHPON='" & txtOHPON & "',OHCNO='" & txtOHCNO & "',OHVDN='" & txtOHVDN & "'" & _
    ",OHCPO='" & cboOHCPO.ListIndex + 1 & "',OHPOS='" & Left(cboOHPOS.List(cboOHPOS.ListIndex), 1) & "',OHCUR='" & cboOHCUR.Text & "',OHPOT='" & cboOHPOT.ListIndex + 1 & "'" & _
    ",OHEXR=" & txtOHEXR & ",OHTAM=" & txtOHTAM & ",OHBTA=" & txtOHBTA & _
    " WHERE OHPON='" & OldOHPON & "'"
    'MsgBox SQL
    DBconn.Execute (sql)
    
    Set recPOL = DBconn.Execute("Select * from POL where OLPON='" & txtOHPON & "' and OLPOL='" & txtOLPOL & "'")
    If txtOLITN <> recPOL!OLITN Then ' Thay doi item moi
        Unt = Val(txtOLODQ)
        WGT = Val(txtOLODW)
        Unt = IIf(IsNumeric(Unt), Unt, 0)
        WGT = IIf(IsNumeric(WGT), WGT, 0)
        'SQL = "Update IIM set IMOOU=IMOOU - (" & Unt & "),IMOOW= IMOOW - (" & WGT & ") where IMITN='" & recPOL!OLITN & "'"
        'DBconn.Execute SQL
        sql = "Update POL set OLLDT='" & txtOLLDT & "',OLITN='" & txtOLITN & "',OLITD='" & txtOLITD & "',OLRID='OM',OLBLA=" & txtOLBLA & ",OLLUS='" & UserLogin & "'" & _
        ",OLUMP='" & txtOLUMP & "',OLLAM='" & txtOLLAM & "',OLPER='" & cboOLPER.ListIndex + 1 & "',OLSTT='" & cboOLSTT.ListIndex + 1 & "'" & _
        ",OLPOL='" & txtOLPOL & "',OLODQ =" & txtOLODQ & ",OLODW=" & txtOLODW & ",OLPDC= " & txtOLPDC & _
        " WHERE OLPON='" & txtOHPON & "' AND OLPOL='" & txtOLPOL & "'"
        DBconn.Execute (sql)
       
    Else
        Unt = Val(txtOLODQ) - recPOL!OLODQ
        WGT = Val(txtOLODW) - recPOL!OLODW
        sql = "Update POL set OLLDT='" & Format(txtOLLDT, "mm/dd/yy") & "',OLITN='" & txtOLITN & "',OLITD='" & txtOLITD & "',OLRID='OM',OLBLA=" & txtOLBLA & ",OLLUS='" & UserLogin & "'" & _
        ",OLUMP='" & txtOLUMP & "',OLLAM='" & txtOLLAM & "',OLPER='" & cboOLPER.ListIndex + 1 & "',OLSTT='" & cboOLSTT.ListIndex + 1 & "'" & _
        ",OLPOL='" & txtOLPOL & "',OLODQ =" & txtOLODQ & ",OLODW=" & txtOLODW & ",OLRCQ =" & txtOLRCQ & ",OLRCW=" & txtOLRCW & ",OLPDC= " & txtOLPDC & _
        " WHERE OLPON='" & txtOHPON & "' AND OLPOL='" & txtOLPOL & "'"
        'MsgBox SQL
        DBconn.Execute (sql)
    End If
    'WriteToIIM WGT, Unt
    'WriteToITH WGT, Unt
End If
recPOL.Close
Adodc4.RecordSource = "select POL.*,POH.* from POL " & _
    " LEFT JOIN POH ON POL.OLPON=POH.OHPON " & _
    " where POL.OLPON='" & txtOHPON & "'" & _
    " Order by OLPOL"

Adodc4.Refresh
End Sub

Private Sub txtOLODW_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtOLUMP.SetFocus
End Sub

Private Sub txtOLODQ_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtOLODW.SetFocus
    
        Dim RecIIM As Recordset
        Set RecIIM = DBconn.Execute("Select IMWPU from IIM where IMITN='" & txtOLITN & "'")
        If Not RecIIM.EOF Then
            txtOLODW = RecIIM!IMWPU * txtOLODQ
        Else
            txtOLODW = 0
        End If
  
End If
End Sub


Private Sub txtOLPDC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then cboOLPER.SetFocus
End Sub

Private Sub txtOLUMP_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtOLPDC.SetFocus
End Sub

Sub WriteToITH(WGT, unit)
unit = IIf(IsNumeric(unit), unit, 0)
 WGT = IIf(IsNumeric(WGT), WGT, 0)
    
If Val(Unt) = 0 And Val(WGT) = 0 Then
   MsgBox "Quantity or Weight must be >0 "
   Exit Sub
End If

'Lay so THTSQ
txtTHTSQ = GetTSQ(txtOLITN)
Dim recITH As Recordset
Set recITH = DBconn.Execute("Select * from ITH Order by THTID DESC")
If recITH.EOF Then
    txtTHTID = 1
Else
    txtTHTID = recITH!THTID + 1
End If
recITH.Close
txtTHITN = txtOLITN
txtTHDOC = txtOHPON
txtTHTTC = "PO"
txtTHDTE = Format(txtOLLDT, "yyyy-mm-dd hh:mm:ss")
txtTHWHC = ""
txtTHLTN = ""
txtTHCST = txtOLUMP
txtTHCVN = txtOHCNO
txtTHREF = txtOHPON
txtTHREM = ""
txtTHDTE = Format(txtTHDTE, "yyyy-mm-dd hh:mm:ss")
sql = "Insert into ITH (THITN,THTSQ,THTID,THDOC,THTTC,THDTE" & _
 ",THWHC,THLTN,THQTY,THWGT,THCST" & _
 ",THCVN,THREF,THREM,THLUS,THLDT) values " & _
 "('" & txtTHITN & "'," & txtTHTSQ & "," & txtTHTID & ",'" & txtTHDOC & "','" & txtTHTTC & "','" & txtTHDTE & "'" & _
 ",'" & txtTHWHC & "','" & txtTHLTN & "'," & unit & "," & WGT & "," & txtTHCST & ",'" & txtTHCVN & "'" & _
 ",'" & txtTHREF & "','" & txtTHREM & "','" & UserLogin & "','" & Format(Now(), "yyyy-mm-dd hh:mm:ss") & "')"
 ' MsgBox SQL
 DBconn.Execute sql

Adodc1.Refresh
End Sub


Sub WriteToIIM(WGT, unit)
'unit = IIf(IsNumeric(unit), unit, 0)
'WGT = IIf(IsNumeric(WGT), WGT, 0)
'SQL = "Update IIM set IMOOU=IMOOU + (" & unit & "),IMOOW= IMOOW + (" & WGT & ") where IMITN='" & txtOLITN & "'"
DBconn.Execute sql
End Sub
    
Sub ClosePO()
    Dim recPOL As Recordset, Line, Item, WGT, Unt, Status
    'Dim recPOH As Recordset
    If (cboOHPOS.ListIndex + 1) = 6 Then
        MsgBox "This Purchase order had been delete"
        Exit Sub
    Else
        
        Set recPOL = DBconn.Execute("Select * from POL where OLPON='" & txtOHPON & "' and OLSTT<>'6'")
        With recPOL
        Do While Not .EOF
            Line = !OLPOL
            Item = !OLITN
            Status = !OLSTT
            ' Chi dong nhung Purchase nao chua hoan thanh
            If Status <> 6 And Status <> 5 Then
                CloseLine Item, Line, WGT, Unt, Status
            End If
            .MoveNext
        Loop
        .Close
        End With
        MsgBox "update POH set OHPOS=5,OHLUS='" & UserLogin & "' WHERE OHPON='" & txtOHPON & "'"
        DBconn.Execute ("update POH set OHPOS=5,OHLUS='" & UserLogin & "' WHERE OHPON='" & txtOHPON & "'")
        
    End If
End Sub
Sub CloseLine(Item, Line, WGT, Unt, Status)
    If Status <> 6 And Status <> 5 Then
        MsgBox "update pol set OLSTT=5" & "OLLUS='" & UserLogin & "',OLLDT='" & Now() & " WHERE OLPON='" & txtOHPON & "' AND OLPOL='" & Line & "'"
        DBconn.Execute ("update pol set OLSTT=5," & "OLLUS='" & UserLogin & "',OLLDT='" & Now() & " WHERE OLPON='" & txtOHPON & "' AND OLPOL='" & Line & "'")
    Else
        MsgBox "This line had been finished or deleted"
    End If
End Sub


Private Function TestPOStatus()
    Dim recPOH As Recordset
    Dim recPOL As Recordset
    TestPOStatus = True
    Set recPOH = DBconn.Execute("SELECT  OHPOS  FROM  POH WHERE OHPON = '" & txtOHPON & "'")
    If recPOH!OHPOS = 5 Then
        MsgBox "This Purchase Order had finished"
        TestPOStatus = False
        Exit Function
    Else
       
        Set recPOL = DBconn.Execute("SELECT  OLSTT  FROM  POL WHERE OLPON = '" & txtOHPON & "'and " & "OLPOL='" & txtOLPOL & "'")
        If recPOH!OHPOS = 5 Then
            MsgBox " Item of This Purchase Order had finished"
            TestPOStatus = False
            Exit Function
        End If
    End If
End Function
